{include file="public/head"}
<style>
    .x-body {
        min-width: 1150px;
    }

    body {
        overflow-x: scroll;
    }

    #table{
        overflow-x: scroll;
    }
    .layui-table {
        min-width: 2000px;
    }
</style>
<body>
<div class="x-body">
    <div class="lotus-nav">
        <button class="layui-btn layui-btn-sm" onclick="x_admin_show('添加','workOrderAdd.html')">
            <i class="layui-icon layui-icon-add-circle"></i>新建
        </button>

        <div class="layui-input-inline">
            <input id="order_number" name="order_number" class="layui-input" placeholder="订单编号"
                   value="{$Think.get.order_number}">
        </div>

        <div class="layui-input-inline">
            <input id="tracking_number" name="tracking_number" class="layui-input" placeholder="客户追踪号"
                   value="{$Think.get.tracking_number}">
        </div>

        <div class="layui-input-inline">
            <input id="reference_number" name="reference_number" class="layui-input" placeholder="客户参考号"
                   value="{$Think.get.reference_number}">
        </div>

        <div class="layui-input-inline layui-form">
            <select name="category" id="category">
                <option value="">问题类型</option>
                {volist name="category" id="vo"}
                {if $Think.get.category == $vo['id']}
                <option value="{$vo.id}" selected>{$vo.category}</option>
                {else/}
                <option value="{$vo.id}">{$vo.category}</option>
                {/if}
                {/volist}
            </select>
        </div>

        <div class="layui-input-inline layui-form">
            <select name="state" id="state">
                <option value="">处理进度</option>
                {volist name="state" id="vo"}
                {if $Think.get.state == $vo['id']}
                <option value="{$vo.id}" selected>{$vo.type}</option>
                {else/}
                <option value="{$vo.id}">{$vo.type}</option>
                {/if}
                {/volist}
            </select>
        </div>
        <br/>
        <div class="layui-input-inline layui-form" style="width: 100px">
            <select name="overdue" id="overdue">
                <option value="">是否过期</option>
                <option value="1" {if $Think.get.overdue== 1} selected {/if}>是</option>
                <option value="2" {if $Think.get.overdue== 2} selected {/if}>否</option>
            </select>
        </div>

        <div class="layui-input-inline layui-form" style="width: 100px">
            <select name="advent" id="advent">
                <option value="">是否临期</option>
                <option value="1" {if $Think.get.advent== 1} selected {/if}>是</option>
                <option value="2" {if $Think.get.advent== 2} selected {/if}>否</option>
            </select>
        </div>

        <div class="layui-input-inline layui-form" style="width: 100px">
            <select name="status" id="status">
                <option value="">工单状态</option>
                <option value="1" {if $Think.get.status== 1} selected {/if}>待处理</option>
                <option value="2" {if $Think.get.status== 2} selected {/if}>处理中</option>
                <option value="3" {if $Think.get.status== 3} selected {/if}>撤回</option>
                <option value="4" {if $Think.get.status== 4} selected {/if}>已完成</option>
            </select>
        </div>

        <div class="layui-input-inline" style="width: 110px">
            <input type="text" class="layui-input" id="start" name="start" value="{$Think.get.start}"
                   placeholder="开始日期">
        </div>

        <div class="layui-input-inline" style="width: 110px">
            <input type="text" class="layui-input" id="end" name="end" value="{$Think.get.end}" placeholder="结束日期">
        </div>

        <button class="layui-btn layui-btn-sm" onclick="search()">
            <i class="layui-icon layui-icon-search"></i>搜索
        </button>

        <span class="x-right">共有数据:<i class="i_count">{$list->total()}</i>条
            <button onclick="javascript:location.reload()" class="layui-btn-default ">
                <i class="layui-icon layui-icon-refresh"></i>
            </button>
        </span>
    </div>

    <div id="table">
    <table class="layui-table">
        <thead>
        <tr>
            <th style="width: 40px;text-align:center"></th>
            <th>标题</th>
            <th style="width: 60px;text-align:center">未读回复</th>
            <th style="min-width: 150px;text-align:center">工单类型</th>
            <th style="min-width: 100px;text-align:center">客户追踪号</th>
            <th style="min-width: 100px;text-align:center">客户参考号</th>
            <th style="width: 100px;text-align:center">处理进度</th>
            <th style="min-width: 100px;text-align:center">订单编号</th>
            <th style="min-width: 100px;text-align:center">AE单号</th>
            <th style="width: 120px;text-align:center">添加时间</th>
            <th style="width: 60px;text-align:center">是否过期</th>
            <th style="width: 80px;text-align:center">处理期限</th>
            <th style="min-width: 100px;text-align:center">运输方式</th>
            <th style="width: 60px;text-align:center">工单状态</th>
            <th style="width: 85px;text-align:center">操作</th>
        </thead>
        <tbody>

        {volist name="list" id="vo"}
        <tr>
            <td style="text-align:center">{$i}</td>
            <td>{$vo.title}</td>
            <td style="text-align:center">{$vo.send_num}</td>
            <td style="text-align:center">{$vo.category}</td>
            <td style="text-align:center">{$vo.tracking_number}</td>
            <td style="text-align:center">{$vo.reference_number}</td>
            <td style="text-align:center">{$vo.state}</td>
            <td style="text-align:center">{$vo.order_number}</td>
            <td style="text-align:center">{$vo.logistics_number}</td>
            <td style="text-align:center">{$vo['timestamp']|date="Y-m-d H:i",###}</td>
            <td style="text-align:center">
                {if $vo['deadline'] > time()}
                <span style="color: green">否</span>
                {else/}
                <span style="color: red">是</span>
                {/if}
            </td>
            <td style="text-align:center">{$vo['deadline']|date="Y-m-d",###}</td>
            <td style="text-align:center">{$vo.transport}</td>
            <td style="text-align:center">
                {switch name="vo.status" }
                {case value="1"}待处理{/case}
                {case value="2"}处理中{/case}
                {case value="3"}撤回{/case}
                {default /}完成
                {/switch}
            </td>
            <td>
                <button class="layui-btn layui-btn-xs"
                        onclick="x_admin_show('工单详情','workOrderEdit.html?id={$vo.id}')">
                    详情
                </button>
                {if $vo.status == 1}
                <button onclick="recall(this,'{$vo.id}')" class="layui-btn layui-btn-xs layui-btn-danger">
                    撤回
                </button>
                {/if}
            </td>
        </tr>
        {/volist}

        </tbody>
    </table>
    </div>

    <div class="page">
        <div>
            {$list->render()}
        </div>
    </div>
</div>
</body>
{include file="public/foot"}
<script>
    function search() {
        var html = '';
        var order_number = $("#order_number").val();
        html += "&order_number=" + order_number;
        var tracking_number = $("#tracking_number").val();
        html += "&tracking_number=" + tracking_number;
        var reference_number = $("#reference_number").val();
        html += "&reference_number=" + reference_number;
        var category = $("#category").val();
        html += "&category=" + category;
        var state = $("#state").val();
        html += "&state=" + state;
        var overdue = $("#overdue").val();
        html += "&overdue=" + overdue;
        var advent = $("#advent").val();
        html += "&advent=" + advent;
        var status = $("#status").val();
        html += "&status=" + status;
        var start = $("#start").val();
        html += "&start=" + start;
        var end = $("#end").val();
        html += "&end=" + end;
        location.href = "myWorkOrder.html?" + html;
    }

    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    function recall(obj, id) {
        layer.confirm('确认要撤回吗？', function (index) {
            //捉到所有被选中的，发异步进行删除
            $.post("{:url('admin/Workorder/workOrderRecall')}", {id: id}, function (data, textStatus, xhr) {
                if (data.code == 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                }

            });
        });
    }
</script>
